/**********************************************************************
 *** *                                                            * ***
 *** *  Copyright (c) 2013 Harmonia Holdings Group LLC            * ***
 *** *                                                            * ***
 *** * Permission is hereby granted to use, modify, copy, and     * ***
 *** * distribute this software and its documentation for any     * ***
 *** * purpose only without profit, provided that the above       * ***
 *** * Copyright Notice appears in all copies and that both the   * ***
 *** * Copyright Notice and this Permission Notice appears in     * ***
 *** * every copy of supporting documentation.  No title to nor   * ***
 *** * ownership of the software is transferred hereby.  The name * ***
 *** * of Harmonia Holdings Group LLC shall not be used in        * ***
 *** * advertising or publicity related to the distribution of    * ***
 *** * the software without specific, written, prior permission.  * ***
 *** * This software is provided as-delivered without expressed   * ***
 *** * or implied warranty.  Harmonia Holdings Group LLC          * ***
 *** * makes no representation about the suitability of this      * ***
 *** * software for any purpose and accepts no responsibility for * ***
 *** * its use.                                                   * ***
 *** *                                                            * ***
 *** ************************************************************** ***
 *** *                                                            * ***
 *** * This program is free software; you can redistribute it     * ***
 *** * and/or modify it under the terms of the GNU General Public * ***
 *** * License as published by the Free Software Foundation;      * ***
 *** * either version 2 of the License, or (at your option) any   * ***
 *** * later version.                                             * ***
 *** *                                                            * ***
 *** * This program is distributed in the hope that it will be    * ***
 *** * useful, but WITHOUT ANY WARRANTY; without even the implied * ***
 *** * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR    * ***
 *** * PURPOSE.  See the GNU General Public License for more      * ***
 *** * details.                                                   * ***
 *** *                                                            * ***
 *** * You should have received a copy of the GNU General Public  * ***
 *** * License along with this program; if not, write to the Free * ***
 *** * Software Foundation, Inc., 51 Franklin Street, Fifth       * ***
 *** * Floor, Boston, MA 02110-1301, USA.                         * ***
 *** *                                                            * ***
 *** * For more information: http://www.gnu.org/licenses/gpl.html * ***
 *** *                                                            * ***
 **********************************************************************/
package org.etexascode.interrep.datamodel;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * The model for a lane movement.
 * @author ablatt
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class LaneMovement implements Serializable {
	/** Serial ID. */
	@XmlTransient
	private static final long serialVersionUID = -6306445106705081573L;

	
	/** Enumeration of movements. */
	@XmlType
	@XmlEnum
	public enum Movement {
		LEFT_TURN, RIGHT_TURN, STRAIGHT, RIGHT_TURN_ON_RED, LEFT_TURN_ON_RED, U_TURN
	};

	
	/** Movement ID. */
	@XmlElement
	private int movementId;
	
	/** Movement. */
	@XmlElement
	private Movement movement;

	
	/** String representation of movement. */
	public String toString() {
		StringBuilder ret = new StringBuilder();

		ret.append("movement id = ");
		ret.append(movementId);
		ret.append("\n");

		ret.append("movement = ");
		ret.append(movement);
		ret.append("\n");

		return ret.toString();
	}

	/** Checks if two lane movements are equal. */
	@Override
	public boolean equals(Object o) {
		if(o instanceof LaneMovement) {
			LaneMovement lm = (LaneMovement)o;
			return (movementId == lm.movementId) && (movement == lm.movement);
		} else {
			return false;
		}
	}
	
	/**
	 * HashCode operation. 
	 * @return A hashcode of the data. 
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(33, 29).
				append(movementId).
				append(movement).
				toHashCode();
	}

	/**
	 * Gets the movement ID.
	 * @return The movement ID.
	 */
	public int getMovementId() {
		return movementId;
	}

	/**
	 * Gets the movement.
	 * @return The movement enumeration value.
	 */
	public Movement getMovement() {
		return movement;
	}

	/**
	 * Sets the movement ID.
	 * @param id The new ID.
	 */
	public void setMovementId(int id) {
		movementId = id;
	}

	/**
	 * Sets the movement.
	 * @param m The new movement.
	 */
	public void setMovement(Movement m) {
		movement = m;
	}
}